Page({
  data: {
    userInfo: {},
    menuItems: [
      {
        id: 1,
        name: '我的订单',
        icon: '/images/order.png'
      },
      {
        id: 2,
        name: '学习记录',
        icon: '/images/record.png'
      },
      {
        id: 3,
        name: '我的收藏',
        icon: '/images/collect.png'
      },
      {
        id: 4,
        name: '设置',
        icon: '/images/settings.png'
      }
    ]
  },

  onLoad() {
    // 获取用户信息
    const userInfo = wx.getStorageSync('userInfo')
    if (userInfo) {
      this.setData({
        userInfo
      })
    }
  },

  handleMenu(e) {
    const id = e.currentTarget.dataset.id
    // 处理菜单点击
    switch(id) {
      case 1:
        wx.navigateTo({url: '/pages/order/order'})
        break
      case 2:
        wx.navigateTo({url: '/pages/record/record'})
        break
      case 3:
        wx.navigateTo({url: '/pages/collect/collect'})
        break
      case 4:
        wx.navigateTo({url: '/pages/settings/settings'})
        break
    }
  }
}) 